/// @tags:
#include <cstdio>
#include <iostream>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 3e5 + 1, maxl = 257;

int a[maxn], f[maxn];

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    for (int i = 0; i < n; ++i) f[i] = 1;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = i - 1; j > -1 && j >= i - maxl; --j) {
        if ((a[j] ^ i) < (a[i] ^ j)) f[i] = std::max(f[i], f[j] + 1);
        ans = std::max(ans, f[i]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("D1_Xor-Subsequence.in", "r", stdin);
  freopen("D1_Xor-Subsequence.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
